```jsx
import { onCleanup, onMount } from "solid-js"
import { trapFocus } from "@zag-js/focus-trap"

export function Dialog() {
  let ref

  onMount(() => {
    if (!ref) return

    const restore = trapFocus(ref, {
      initialFocus: "[data-autofocus]",
    })

    onCleanup(() => {
      restore()
    })
  })

  return (
    <div ref={ref}>
      <button data-autofocus>Close</button>
      <input type="text" placeholder="Enter text..." />
      <button>Submit</button>
    </div>
  )
}
```
